package com.shi.demo.mapper;

import com.shi.demo.pojo.Emp;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface EmpMapper {

    @Delete("delete from emp where id=#{id}")
    public void deleteById(Integer id);

    //新增操作
    @Options(useGeneratedKeys = true,keyProperty = "id")//返回主键id
    @Insert("insert into emp(username, name, gender, image, job, entrydate, dept_id, create_time, update_time) " +
            "values (#{username},#{name},#{gender},#{image},#{job},#{entrydate},#{deptId},#{createTime},#{updateTime})")
    public void insert(Emp emp);

    //更新操作

    @Update("update emp set username=#{username},name=#{name},gender=#{gender},image=#{image},job=#{job},entrydate=#{entrydate},dept_id=#{deptId},update_time=#{updateTime} where id=#{id}")
    public void update(Emp emp);

    //根据id查询
    @Select("select * from emp where id=#{id}")
    public Emp getById(Integer id);

    //动态查询
    public List<Emp> getAll(String name, Short gender, LocalDate begin,LocalDate end);

    //批量删除
    public void deleteByIds(List<Integer> ids);

}
